// To parse this JSON data, do
//
//     final trajectoryListModel = trajectoryListModelFromJson(jsonString);

import 'dart:convert';

TrajectoryListModel trajectoryListModelFromJson(String str) => TrajectoryListModel.fromJson(json.decode(str));

String trajectoryListModelToJson(TrajectoryListModel data) => json.encode(data.toJson());

class TrajectoryListModel {
  Meta meta;
  List<ListElement> list;

  TrajectoryListModel({
    required this.meta,
    required this.list,
  });

  factory TrajectoryListModel.fromJson(Map<String, dynamic> json) => TrajectoryListModel(
    meta: Meta.fromJson(json["meta"]),
    list: List<ListElement>.from(json["list"].map((x) => ListElement.fromJson(x))),
  );

  Map<String, dynamic> toJson() => {
    "meta": meta.toJson(),
    "list": List<dynamic>.from(list.map((x) => x.toJson())),
  };
}

class ListElement {
  int id;
  String caption;
  var distance;
  DateTime time;
  var finished;
  String detailUrl;

  ListElement({
    required this.id,
    required this.caption,
    required this.distance,
    required this.time,
    required this.finished,
    required this.detailUrl,
  });

  factory ListElement.fromJson(Map<String, dynamic> json) => ListElement(
    id: json["id"],
    caption: json["caption"],
    distance: json["distance"] ,
    time: DateTime.parse(json["time"]),
    finished: json["finished"],
    detailUrl: json["detailUrl"],
  );

  Map<String, dynamic> toJson() => {
    "id": id,
    "caption": caption,
    "distance": distance,
    "time": "${time.year.toString().padLeft(4, '0')}-${time.month.toString().padLeft(2, '0')}-${time.day.toString().padLeft(2, '0')}",
    "finished": finished,
    "detailUrl": detailUrl,
  };
}

class Meta {
  int currentPage;
  int maxPage;
  int itemCount;
  int pageSize;

  Meta({
    required this.currentPage,
    required this.maxPage,
    required this.itemCount,
    required this.pageSize,
  });

  factory Meta.fromJson(Map<String, dynamic> json) => Meta(
    currentPage: json["currentPage"],
    maxPage: json["maxPage"],
    itemCount: json["itemCount"],
    pageSize: json["pageSize"],
  );

  Map<String, dynamic> toJson() => {
    "currentPage": currentPage,
    "maxPage": maxPage,
    "itemCount": itemCount,
    "pageSize": pageSize,
  };
}
